﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for HoaDon
/// </summary>
public class HoaDon
{
	public HoaDon()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public int DonHangID { get; set; }
    public int KhachHangID { get; set; }
    public string DiaChiNguoiNhan { get; set; }
    public string HoTenNguoiNhan { get; set; }
    public string SDTNguoiNhan { get; set; }
    public string Email { get; set; }

    public int TongTien { get; set; }
    public bool DaGiao { get; set; }

    AccessData ac = new AccessData();
    public void Insert(HoaDon hd)
    {
        SqlConnection con = ac.GetConnect();
        con.Open();
        SqlCommand cmd = new SqlCommand("DONDATHANG_THEM", con);
        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        cmd.Parameters.Add("@KhachHangID", System.Data.SqlDbType.Int).Value = hd.KhachHangID;
        cmd.Parameters.Add("@DiaChiNguoiNhan", System.Data.SqlDbType.NVarChar).Value = hd.DiaChiNguoiNhan;
        cmd.Parameters.Add("@HoTenNguoiNhan", System.Data.SqlDbType.NVarChar).Value = hd.HoTenNguoiNhan;
        cmd.Parameters.Add("@SDTNguoiNhan", System.Data.SqlDbType.VarChar).Value = hd.SDTNguoiNhan;
        cmd.Parameters.Add("@Email", System.Data.SqlDbType.NVarChar).Value = hd.Email;
        cmd.Parameters.Add("@TongTien", System.Data.SqlDbType.Int).Value = hd.TongTien;
        cmd.Parameters.Add("@DaGiao", System.Data.SqlDbType.Bit).Value = hd.DaGiao;
        cmd.ExecuteNonQuery();
        cmd.Dispose();
        con.Close();
    }
}